package com.swallow.user.tool;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;

import java.util.Collections;

public class CodeGenerator {
    public static void main(String[] args) {
        FastAutoGenerator.create("jdbc:mysql://localhost:3307/cloud_demo", "root", "mayuqing")
                .globalConfig(builder -> {
                    builder.author("mayuqing") // 设置作者
                            .outputDir("D:\\ProjectCode\\ServerCode\\cloud_demo\\user\\src\\main\\java\\com\\swallow\\user"); // 指定输出目录
                })
                .packageConfig(builder -> {
                    builder.parent("com.swallow.user") // 设置父包名
                            .pathInfo(Collections.singletonMap(OutputFile.xml, "D:\\ProjectCode\\ServerCode\\cloud_demo\\user\\src\\main\\resources")); // 设置mapperXml生成路径
                })
                .strategyConfig(builder -> {
                    builder.addInclude("user") // 设置需要生成的表名
                            .addTablePrefix("t_", "sys_"); // 设置过滤表前缀
                })
                .execute();
    }
}